<?php
class Tags extends AppModel{
    var $useTable = "rs_tags";
    public $name = "Tags";
	var $primaryKey = "tagsId";
    var $belongsTo = array('Meta' =>
        array('className'    => 'Meta',
            'conditions'   => '',
            'order'        => '',
            'fields'        => array('Meta.tagsId','Meta.newsId','Meta.metaId'),
            'dependent'    =>  true,
            'foreignKey'   => 'TagsId'
        )
    );
	
    public function is_existed_tag($tag){
        $check = $this->find('count', array(
                'conditions' => array('Tags.tags' => $tag)
            ));
        if($check == 0) return false;
        else return true;
    }

    public function get_existed_tag_id($tag){
        $tag = $this->find('first', array(
            'conditions' => array('Tags.tags' => $tag)
        ));
        return $tag['Tags']['tagsId'];
    }
}